cmake_minimum_required(VERSION 3.28)
project(data_cpp_1)

set(CMAKE_CXX_STANDARD 17)

# 基础方案：扫描所有 .cpp 文件并查找 main 函数
file(GLOB_RECURSE ALL_CPP_FILES "*.cpp")
foreach(file ${ALL_CPP_FILES})
    file(STRINGS ${file} has_main REGEX "int[ \t]+main[ \t]*\\(")
    if(has_main)
        get_filename_component(name ${file} NAME_WE)
        add_executable(${name} ${file})
    endif()
endforeach()